//
//  DKAuthBackAlertView.m
//  DanKU
//
//  Created by 吴斌 on 2023/10/29.
//

#import "DKAuthBackAlertView.h"
@interface DKAuthBackAlertView()
@property (nonatomic, weak)zhPopupController * dk_AuthBackAlertViewPop;
@property (nonatomic,strong)DKAuthBackAlertView *dk_AuthBackAlertView;
@property (nonatomic, copy)void(^SureScuessAuthAlertBlock)(void);
@end
@implementation DKAuthBackAlertView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.whiteColor;
        self.layer.cornerRadius = 50;
        self.clipsToBounds = YES;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UILabel *dk_AuthStartContentLab = [[UILabel alloc] init];
    dk_AuthStartContentLab.textColor = DK_Hex(@"#4566FF");
    dk_AuthStartContentLab.font = DK_FONT_Medium(17);
    dk_AuthStartContentLab.numberOfLines = 0;
    dk_AuthStartContentLab.textAlignment = NSTextAlignmentCenter;
    dk_AuthStartContentLab.text = @"We have achieved the best product portfolio for you with a 90% approval rateapply now！";
    [self addSubview:dk_AuthStartContentLab];
    [dk_AuthStartContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(58)));
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(6)));
    }];
    UIButton * dk_AuthStartBtn = [[UIButton alloc] init];
    [dk_AuthStartBtn setTitle:@"Not now" forState:UIControlStateNormal];
    [dk_AuthStartBtn setTitleColor:DK_Hex(@"#FFFFFF") forState:UIControlStateNormal];
    dk_AuthStartBtn.titleLabel.font = DK_FONT_Semibold(16);
    [dk_AuthStartBtn setBackgroundColor:DK_Hex(@"#4566FF")];
    dk_AuthStartBtn.layer.cornerRadius = DK_IsWidthScale(25);
    dk_AuthStartBtn.clipsToBounds = YES;
    [dk_AuthStartBtn addTarget:self action:@selector(startAuth) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:dk_AuthStartBtn];
    [dk_AuthStartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.right.equalTo(@(-DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(50)));
        make.bottom.equalTo(@(-DK_IsWidthScale(40)));
    }];
}
- (void)startAuth{
    if(self.SureScuessAuthAlertBlock){
        [_dk_AuthBackAlertViewPop dismiss];
        self.SureScuessAuthAlertBlock();
    }
}
+ (void)dk_ShowAuthBackAlertView:(void(^)(void))complete{
    DKAuthBackAlertView * dk_AuthBackAlertView = [[DKAuthBackAlertView alloc] init];
    zhPopupController * sureAuthScuessCtrl = [[zhPopupController alloc] initWithView:dk_AuthBackAlertView size:CGSizeMake(DK_SCREEN_W - DK_IsWidthScale(60), DK_IsWidthScale(248))];
    dk_AuthBackAlertView.SureScuessAuthAlertBlock = complete;
    sureAuthScuessCtrl.presentationStyle = zhPopupSlideStyleTransform;
    sureAuthScuessCtrl.layoutType = zhPopupLayoutTypeCenter;
    sureAuthScuessCtrl.presentationTransformScale = 0.56;
    sureAuthScuessCtrl.dismissonTransformScale = 0.56;
    sureAuthScuessCtrl.dismissOnMaskTouched = NO;
    dk_AuthBackAlertView.dk_AuthBackAlertViewPop = sureAuthScuessCtrl;
    [sureAuthScuessCtrl showInView:((AppDelegate*)([UIApplication sharedApplication].delegate)).window completion:^{
    }];
}
@end
